define(['jquery', 'bootstrap', 'fast', 'form','vue'], function ($, undefined, Fast, Form,Vue) {

    var Controller = {
        index: function () {  
            require(['bootstrap-daterangepicker'], function () {
                var ranges = {};
                ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
                ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
                ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
                ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
                ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
                ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
                var options = {
                    timePicker: false,
                    autoUpdateInput: false,
                    timePickerSeconds: true,
                    timePicker24Hour: true,
                    autoApply: true,
                    locale: {
                        format: 'YYYY-MM-DD',
                        customRangeLabel: __("Custom Range"),
                        applyLabel: __("Apply"),
                        cancelLabel: __("Clear"),
                    },
                    ranges: ranges,
                };
                var origincallback = function (start, end) {
                    $('input[name=start]').val(start.format(this.locale.format));
                    $('input[name=end]').val(end.format(this.locale.format));
                    $('#searchShow').click();
                };
                $(".daterange").each(function () {
                    var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
                    $(this).on('apply.daterangepicker', function (ev, picker) {
                        callback.call(picker, picker.startDate, picker.endDate);
                    });
                    $(this).on('cancel.daterangepicker', function (ev, picker) {
                        $(this).val('').trigger('change').trigger('validate');
                    });
                    $(this).daterangepicker($.extend(true, {}, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
                });
            });
            
            const vm =new Vue({
                el: '#app',
                data:{
                    commondata:['wr','week','days','fa'],
                    wdgroud:['wd','wf'],
                    selectTabble:true,               
                    user:null,//用户信息
                    head:[], //头部导航
                    banner:[],//轮播图
                    searchQuery: '',//搜索框
                    suggestions: [],//搜索建议
                    showSuggestions: false,//是否显示建议列表
                    selectedIndex: -1,//当前选中的建议索引
                    currentCategory: 0,//当前选中的分类
                    expandedCategories: {},//展开的分类
                    currentTab:'hot',//当前选中的tab
                    itemTab:0,
                    page:1,
                    list:[],
                    wdcate:[],//分类
                    sortBy: 'latest',
                    dateRange: {
                        start:'',
                        end:''
                    },
                    more:true,
                    officialColumns: [
                        { title: '令牌悬赏', postCount: 165, image: '/assets/img/logo.png', url: '#' },
                        { title: '会员日', postCount: 302, image: '/assets/img/logo.png', url: '#' },
                        { title: '闻钱的收藏', postCount: 1030, image: '/assets/img/logo.png', url: '#' }
                    ],
                },
                created() {
                    that = this;
                    Fast.api.ajax({
                        url: "ajax/auth",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.user = result.data;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/getcate",
                        loading: false,
                        async:true,
                        success:function(result) {

                            if (result.code == 200) {
                                that.banner = result.data.banner;
                                that.head = result.data.head;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/wdcate",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.wdcate = result.data;
                            }
                        }
                    });
                    this.getData();
                    
                },
                mounted() {
                    if (this.$el.contains(this.$refs.loadNode)) {
                        this.$el.removeChild(this.$refs.loadNode);
                    }
                    // 点击页面其他地方时关闭建议列表
                    document.addEventListener('click', (e) => {
                        if (!e.target.closest('.search-box')) {
                            that.showSuggestions = false;
                        }
                    });
                   
                    window.addEventListener('scroll', this.handleScroll);
                },
                beforeDestroy() {
                  // 页面销毁前移除滚动事件监听
                  window.removeEventListener('scroll', this.handleScroll);
                },
                methods:{
                    showFlag(id){
                        Fast.api.open('/member/submit?c=flag&t=document&id='+id,'赠送锦旗',{
                            maxmin: false,
                            shadeClose:false,
                            area:['300px','400px'],
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showComment(id){
                        Fast.api.open('/member/submit?c=comment&t=document&id='+id,'我要评论',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showFavorites(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'document',id:id,c:'fa'},
                        });
                    },
                    showFollow(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'document',id:id,c:'fo'},
                        });
                    },
                    handleScroll() {
                        const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
                        const windowHeight = window.innerHeight || document.documentElement.clientHeight;
                        const documentHeight = document.documentElement.scrollHeight;
                        if (scrollTop + windowHeight >= (documentHeight-30)) {
                            that.getData();
                        }
                    },
                    handle(url,isLogin){

                        if(isLogin && !this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(isLogin && this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        window.location.href = url;
                    },
                    handleDetail(item){
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        switch (item.type) {
                            case 'wd':
                                url = '/wdgroup/detail?id='+item.doc_id;
                                break;
                            case 'wf':
                                url = '/wfgroup/detail?id='+item.doc_id;
                                break;
                            case 'wp':
                                url = '/wpgroup/detail?id='+item.doc_id;
                                break;
                            case 'wr':
                                if(this.user.level == 0){
                                    Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(){
                                        that.handleBuy();
                                    });
                                    return;
                                }
                                url = '/resource/detail?id='+item.doc_id;
                                break;
                            case 'fa':
                                    url = '/favorites/detail?id='+item.doc_id;
                                    break;
                            case 'week':
                                url = '/week/detail?id='+item.doc_id;
                                break;
                            case 'days':
                                url = '/days/detail?id='+item.doc_id;
                                break;
                        }
                        window.location.href = url;
                    },
                    handCate(item){
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return ;
                        }
                        if(item.user_level_id >0 && !this.user.group_id.includes(item.user_level_id)){
                            
                            Fast.api.layer.confirm('本小组为申请制,仅提交申请并审核通过的会员可加入', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleAudit(item.user_level_id);
                            });
                            return ;
                        }
                       
                        this.itemTab = item.id;
                        window.location.href = '/wdgroup?wdid='+item.id;
                    },
                    handleSort(sort) {
                        this.sortBy = sort;
                        this.handleShow();
                    }, 
                    handleBuy(){
                        Fast.api.open('/member/level','会员购买',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleAudit(level){
                        Fast.api.open('/member/audit?id='+level,'我要申请',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleShow() {
                        
                        this.dateRange.start = document.querySelector('[name="start"]').value;
                        this.dateRange.end = document.querySelector('[name="end"]').value;
                        this.page = 1;
                        this.more = true;
                        this.getData();                       
                    },
                    handleCurrent(tab) {
                        this.currentTab = tab;
                        this.handleShow();
                    },
                    getData(){
                        let that = this;
                        if(that.more == false){
                            return;
                        }
                        if(that.page > 1){
                            if(!this.user){
                                window.location.href = '/login';
                                return;
                            }
                            if( this.user.level == 0){
                                Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                    Fast.api.close(index);
                                    that.handleBuy();
                                });
                                return ;
                            }
                        }
                        // 在这里处理日期变化后的逻辑
                        const form = {
                            keywords:this.searchQuery,
                            index:this.currentTab,
                            sort:this.sortBy,
                            start:this.dateRange.start,
                            end:this.dateRange.end,
                            page:this.page
                        }
                        let page = this.page;
                        Fast.api.ajax({
                            url: 'index/index',
                            data: form,
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                   if(that.page == 1){
                                    that.list = result.data;
                                   }else{
                                    that.list.push(...result.data);
                                   }
                                   if(result.data.length <10){
                                    that.more = false;
                                   }
                                   that.page = page+1;
                                }
                                
                            }
                        });
                    },
                    handleSearch() {
                        if (!this.searchQuery) {
                            this.suggestions = [];
                            this.showSuggestions = false;
                            return;
                        } 
                        Fast.api.ajax({
                            url: 'ajax/searchlog',
                            data: {
                                query: this.searchQuery,
                            },
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                    that.suggestions = result.data;
                                    that.showSuggestions = true;
                                    that.selectedIndex = -1;
                                }
                            }
                        });
                        
                    },
                    handleKeyDown(e) {
                        if (!this.suggestions.length) return;
                    
                        switch(e.key) {
                            case 'ArrowDown':
                                e.preventDefault();
                                this.selectedIndex = (this.selectedIndex + 1) % this.suggestions.length;
                                break;
                            case 'ArrowUp':
                                e.preventDefault();
                                this.selectedIndex = this.selectedIndex <= 0 ? this.suggestions.length - 1 : this.selectedIndex - 1;
                                break;
                            case 'Enter':
                                if (this.selectedIndex > -1) {
                                    this.selectSuggestion(this.suggestions[this.selectedIndex]);
                                } else {
                                    this.submitSearch();
                                }
                                break;
                            case 'Escape':
                                this.showSuggestions = false;
                                break;
                        }
                    },
                    selectSuggestion(item) {
                        this.searchQuery = item.name;
                        this.showSuggestions = false;
                        
                    },
                    submitSearch() {
                       this.handleShow();
                    },
                    handleSelect(){
                       this.selectTabble = !this.selectTabble;
                    }
                }
            });
    
        },
        wdgroup: function () {  
            require(['bootstrap-daterangepicker'], function () {
                var ranges = {};
                ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
                ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
                ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
                ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
                ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
                ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
                var options = {
                    timePicker: false,
                    autoUpdateInput: false,
                    timePickerSeconds: true,
                    timePicker24Hour: true,
                    autoApply: true,
                    locale: {
                        format: 'YYYY-MM-DD',
                        customRangeLabel: __("Custom Range"),
                        applyLabel: __("Apply"),
                        cancelLabel: __("Clear"),
                    },
                    ranges: ranges,
                };
                var origincallback = function (start, end) {
                    $('input[name=start]').val(start.format(this.locale.format));
                    $('input[name=end]').val(end.format(this.locale.format));
                    $('#searchShow').click();
                };
                $(".daterange").each(function () {
                    var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
                    $(this).on('apply.daterangepicker', function (ev, picker) {
                        callback.call(picker, picker.startDate, picker.endDate);
                    });
                    $(this).on('cancel.daterangepicker', function (ev, picker) {
                        $(this).val('').trigger('change').trigger('validate');
                    });
                    $(this).daterangepicker($.extend(true, {}, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
                });
            });
            const vm =new Vue({
                el: '#app',
                data:{               
                    user:null,//用户信息
                    head:[], //头部导航
                    banner:[],//轮播图
                    searchQuery: '',//搜索框
                    suggestions: [],//搜索建议
                    showSuggestions: false,//是否显示建议列表
                    selectedIndex: -1,//当前选中的建议索引
                    currentCategory: wpid,//当前选中的分类
                    expandedCategories: {},//展开的分类
                    currentTab:'hot',//当前选中的tab
                    itemTab:wdid,
                    list:[],
                    article:[],//文章
                    articletab:0,
                    page:1,
                    fuser:[],
                    wdcate:[],//分类
                    sortBy: 'latest',
                    dateRange: {
                        start:'',
                        end:''
                    },
                    more:true,
                    officialColumns: [
                        { title: '令牌悬赏', postCount: 165, image: '/assets/img/logo.png', url: '#' },
                        { title: '会员日', postCount: 302, image: '/assets/img/logo.png', url: '#' },
                        { title: '闻钱的收藏', postCount: 1030, image: '/assets/img/logo.png', url: '#' }
                    ],
                },
                created() {
                    that = this;
                    Fast.api.ajax({
                        url: "ajax/auth",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.user = result.data;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/getcate",
                        loading: false,
                        async:true,
                        success:function(result) {

                            if (result.code == 200) {
                                that.banner = result.data.banner;
                                that.head = result.data.head;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/wdcate",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.wdcate = result.data;
                                
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/featureduser",
                        loading: false,
                        async:true,
                        data: {cate_id:this.itemTab},
                        success:function(result) {
                            if (result.code == 200) {
                                that.fuser = result.data;
                            }
                        }
                    });
                    this.getData();
                    this.handleArticle(0);
                },
                mounted() {
                    if (this.$el.contains(this.$refs.loadNode)) {
                        this.$el.removeChild(this.$refs.loadNode);
                    }
                    // 点击页面其他地方时关闭建议列表
                    document.addEventListener('click', (e) => {
                        if (!e.target.closest('.search-box')) {
                            that.showSuggestions = false;
                        }
                    });
                   
                    window.addEventListener('scroll', this.handleScroll);
                   
                },
                beforeDestroy() {
                    // 页面销毁前移除滚动事件监听
                    window.removeEventListener('scroll', this.handleScroll);
                  },
                methods:{
                    showFlag(id){
                        Fast.api.open('/member/submit?c=flag&t=wd&id='+id,'赠送锦旗',{
                            maxmin: false,
                            shadeClose:false,
                            area:['300px','400px'],
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showComment(id){
                        Fast.api.open('/member/submit?c=comment&t=wd&id='+id,'我要评论',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showFavorites(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'wd',id:id,c:'fa'},
                            
                        });
                    },
                    showFollow(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'wd',id:id,c:'fo'},
                            
                        });
                    },
                    handleScroll() {
                        const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
                        const windowHeight = window.innerHeight || document.documentElement.clientHeight;
                        const documentHeight = document.documentElement.scrollHeight;
                        if (scrollTop + windowHeight >= (documentHeight-30)) {
                            that.getData();
                        }
                    },
                    handle(url,isLogin){

                        if(isLogin && !this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(isLogin && this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        window.location.href = url;
                    },
                    handleArticle(tab){
                        this.articletab = tab;
                        Fast.api.ajax({
                            url: 'ajax/wdocument',
                            data: {type:this.articletab,cate_id:this.itemTab},
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                    that.article = result.data;
                                }
                                
                            }
                        });
                    },
                    handleBuy(){
                        Fast.api.open('/member/level','会员购买',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleAdd(){
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可发布', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        Fast.api.open('index/add','发布帖子',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success('发布成功,等待审核');
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleAudit(level){
                        Fast.api.open('/member/audit?id='+level,'我要申请',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handCate(item){
                        let that = this;
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if( this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return ;
                        }
                        if(item.user_level_id >0 && !this.user.group_id.includes(item.user_level_id)){
                            
                            Fast.api.layer.confirm('本小组为申请制,仅提交申请并审核通过的会员可加入', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleAudit(item.user_level_id);
                            });
                            return ;
                        }
                       
                        this.itemTab = item.id;
                        window.location.href = '/wdgroup?wdid='+item.id;
                    },
                    handleSort(sort) {
                        this.sortBy = sort;
                        this.handleShow();
                    }, 
                    handleShow() {
                        
                        this.dateRange.start = document.querySelector('[name="start"]').value;
                        this.dateRange.end = document.querySelector('[name="end"]').value;
                        this.page = 1;
                        this.more =true;
                        this.getData();                       
                    },
                    handleCurrent(tab) {
                        this.currentTab = tab;
                        this.handleShow();
                    },
                    getData(){
                        let that = this;
                        if(that.more == false){
                            return;
                        }
                        if(that.page > 1){
                            if(!this.user){
                                window.location.href = '/login';
                                return;
                            }
                            if( this.user.level == 0){
                                Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                    Fast.api.close(index);
                                    that.handleBuy();
                                });
                                return ;
                            }
                        }
                        // 在这里处理日期变化后的逻辑
                        const form = {
                            id:this.itemTab,
                            keywords:this.searchQuery,
                            index:this.currentTab,
                            sort:this.sortBy,
                            start:this.dateRange.start,
                            end:this.dateRange.end,
                            page:this.page
                        }
                        Fast.api.ajax({
                            url: 'index/wdgroup',
                            data: form,
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                   if(that.page == 1){
                                    that.list = result.data;
                                   }else{
                                    that.list.push(...result.data);
                                   }
                                   if(result.data.length <10){
                                    that.more = false;
                                   }
                                   page = that.page;
                                   that.page = page+1;
                                }
                            }
                        });
                    },
                    handleSearch() {
                        if (!this.searchQuery) {
                            this.suggestions = [];
                            this.showSuggestions = false;
                            return;
                        }
                        Fast.api.ajax({
                            url: 'ajax/searchlog',
                            data: {
                                query: this.searchQuery,
                            },
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                    that.suggestions = result.data;
                                    that.showSuggestions = true;
                                    that.selectedIndex = -1;
                                }
                            }
                        });
                        
                    },
                    handleKeyDown(e) {
                        if (!this.suggestions.length) return;
                    
                        switch(e.key) {
                            case 'ArrowDown':
                                e.preventDefault();
                                this.selectedIndex = (this.selectedIndex + 1) % this.suggestions.length;
                                break;
                            case 'ArrowUp':
                                e.preventDefault();
                                this.selectedIndex = this.selectedIndex <= 0 ? this.suggestions.length - 1 : this.selectedIndex - 1;
                                break;
                            case 'Enter':
                                if (this.selectedIndex > -1) {
                                    this.selectSuggestion(this.suggestions[this.selectedIndex]);
                                } else {
                                    this.submitSearch();
                                }
                                break;
                            case 'Escape':
                                this.showSuggestions = false;
                                break;
                        }
                    },
                    selectSuggestion(item) {
                        this.searchQuery = item.name;
                        this.showSuggestions = false;
                        
                    },
                    submitSearch() {
                        this.handleShow();
                    }
                }
            });
            
        },
        add: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        detail:function(){
            const vm =new Vue({
                el: '#app',
                data:{               
                    user:null,//用户信息
                    head:[], //头部导航
                    item:null,
                },
                created() {
                    that = this;
                    Fast.api.ajax({
                        url: "ajax/auth",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.user = result.data;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/getcate",
                        loading: false,
                        async:true,
                        success:function(result) {

                            if (result.code == 200) {
                                
                                that.head = result.data.head;
                            }
                        }
                    });
                    this.getData();
                    console.log(this.item);
                },
                mounted() {
                    console.log(this.item);
                    if (this.$el.contains(this.$refs.loadNode)) {
                        this.$el.removeChild(this.$refs.loadNode);
                    }
                },
                methods:{
                    handleAttention(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'wd',id:id,c:'at'},
                            success:function(data) 
                            {
                                if (data.code == 1) {
                                    Fast.api.toastr.success(data.msg);
                                }else{
                                    Fast.api.toastr.error(data.msg);
                                }
                            },
                            error:function(data) {
                                Fast.api.toastr.error(data.msg);
                            }
                        });
                    },
                    showFlag(id){
                        Fast.api.open('/member/submit?c=flag&t=wd&id='+id,'赠送锦旗',{
                            maxmin: false,
                            shadeClose:false,
                            area:['300px','400px'],
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showComment(id){
                        Fast.api.open('/member/submit?c=comment&t=wd&id='+id,'我要评论',{
                            minmax: false,
                            shadeClose:false,
                            
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showFavorites(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'wd',id:id,c:'fa'}, 
                        });
                    },
                    showFollow(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'wd',id:id,c:'fo'},
                        });
                    },

                    handle(url,isLogin){
                        let that = this;
                        if(isLogin && !this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(isLogin && this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        window.location.href = url;
                    },
                    handleBuy(){
                        Fast.api.open('/member/level','会员购买',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    getData(){
                        let that = this;
                        // 在这里处理日期变化后的逻辑
                        const form = {
                            id:aid,
                        }
                        Fast.api.ajax({
                            url: 'index/detail',
                            data: form,
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                    that.item = result.data;
                                }
                            }
                        });
                    }
                }
            });
        },
        about:function(){
            const vm =new Vue({
                el: '#app',
                data:{               
                    user:null,//用户信息
                    head:[], //头部导航
                    item:null,
                },
                created() {
                    that = this;
                    Fast.api.ajax({
                        url: "ajax/auth",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.user = result.data;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/getcate",
                        loading: false,
                        async:true,
                        success:function(result) {

                            if (result.code == 200) {
                                
                                that.head = result.data.head;
                            }
                        }
                    });
                },
                mounted() {
                    console.log(this.item);
                    if (this.$el.contains(this.$refs.loadNode)) {
                        this.$el.removeChild(this.$refs.loadNode);
                    }
                },
                methods:{
                    
                    handle(url,isLogin){
                        let that = this;
                        if(isLogin && !this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(isLogin && this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        window.location.href = url;
                    },
                    
                    handleBuy(){
                        Fast.api.open('/member/level','会员购买',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    
                }
            });
        },
        reward: function () {  
            require(['bootstrap-daterangepicker'], function () {
                var ranges = {};
                ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
                ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
                ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
                ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
                ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
                ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
                var options = {
                    timePicker: false,
                    autoUpdateInput: false,
                    timePickerSeconds: true,
                    timePicker24Hour: true,
                    autoApply: true,
                    locale: {
                        format: 'YYYY-MM-DD',
                        customRangeLabel: __("Custom Range"),
                        applyLabel: __("Apply"),
                        cancelLabel: __("Clear"),
                    },
                    ranges: ranges,
                };
                var origincallback = function (start, end) {
                    $('input[name=start]').val(start.format(this.locale.format));
                    $('input[name=end]').val(end.format(this.locale.format));
                    $('#searchShow').click();
                };
                $(".daterange").each(function () {
                    var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
                    $(this).on('apply.daterangepicker', function (ev, picker) {
                        callback.call(picker, picker.startDate, picker.endDate);
                    });
                    $(this).on('cancel.daterangepicker', function (ev, picker) {
                        $(this).val('').trigger('change').trigger('validate');
                    });
                    $(this).daterangepicker($.extend(true, {}, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
                });
            });
            
            const vm =new Vue({
                el: '#app',
                data:{
                    commondata:['wr','week','days','fa'],
                    wdgroud:['wd','wf'],
                    selectTabble:true,               
                    user:null,//用户信息
                    head:[], //头部导航
                    banner:[],//轮播图
                    searchQuery: '',//搜索框
                    suggestions: [],//搜索建议
                    showSuggestions: false,//是否显示建议列表
                    selectedIndex: -1,//当前选中的建议索引
                    currentCategory: 0,//当前选中的分类
                    expandedCategories: {},//展开的分类
                    currentTab:'all',//当前选中的tab
                    itemTab:0,
                    page:1,
                    list:[],
                    wdcate:[],//分类
                    sortBy: 'latest',
                    dateRange: {
                        start:'',
                        end:''
                    },
                    more:true,
                    officialColumns: [
                        { title: '令牌悬赏', postCount: 165, image: '/assets/img/logo.png', url: '#' },
                        { title: '会员日', postCount: 302, image: '/assets/img/logo.png', url: '#' },
                        { title: '闻钱的收藏', postCount: 1030, image: '/assets/img/logo.png', url: '#' }
                    ],
                },
                created() {
                    that = this;
                    Fast.api.ajax({
                        url: "ajax/auth",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.user = result.data;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/getcate",
                        loading: false,
                        async:true,
                        success:function(result) {

                            if (result.code == 200) {
                                that.head = result.data.head;
                            }
                        }
                    });
                    
                    this.getData();
                    
                },
                mounted() {
                    if (this.$el.contains(this.$refs.loadNode)) {
                        this.$el.removeChild(this.$refs.loadNode);
                    }
                    // 点击页面其他地方时关闭建议列表
                    document.addEventListener('click', (e) => {
                        if (!e.target.closest('.search-box')) {
                            that.showSuggestions = false;
                        }
                    });
                   
                    window.addEventListener('scroll', this.handleScroll);
                },
                beforeDestroy() {
                  // 页面销毁前移除滚动事件监听
                  window.removeEventListener('scroll', this.handleScroll);
                },
                methods:{
                    showFlag(id){
                        Fast.api.open('/member/submit?c=flag&t=document&id='+id,'赠送锦旗',{
                            maxmin: false,
                            shadeClose:false,
                            area:['300px','400px'],
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showComment(id){
                        Fast.api.open('/member/submit?c=comment&t=document&id='+id,'我要评论',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showFavorites(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'document',id:id,c:'fa'},
                        });
                    },
                    showFollow(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'document',id:id,c:'fo'},
                        });
                    },
                    handleScroll() {
                        const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
                        const windowHeight = window.innerHeight || document.documentElement.clientHeight;
                        const documentHeight = document.documentElement.scrollHeight;
                        if (scrollTop + windowHeight >= (documentHeight-30)) {
                            that.getData();
                        }
                    },
                    handle(url,isLogin){

                        if(isLogin && !this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(isLogin && this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        window.location.href = url;
                    },
                    handleDetail(item){
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        switch (item.type) {
                            case 'wd':
                                url = '/wdgroup/detail?id='+item.doc_id;
                                break;
                            case 'wf':
                                url = '/wfgroup/detail?id='+item.doc_id;
                                break;
                            case 'wp':
                                url = '/wpgroup/detail?id='+item.doc_id;
                                break;
                            case 'wr':
                                if(this.user.level == 0){
                                    Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                        Fast.api.close(index);
                                        that.handleBuy();
                                    });
                                    return;
                                }
                                url = '/resource/detail?id='+item.doc_id;
                                break;
                            case 'fa':
                                    url = '/favorites/detail?id='+item.doc_id;
                                    break;
                            case 'week':
                                url = '/week/detail?id='+item.doc_id;
                                break;
                            case 'days':
                                url = '/days/detail?id='+item.doc_id;
                                break;
                        }
                        window.location.href = url;
                    },
                    handCate(item){
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(){
                                that.handleBuy();
                            });
                            return ;
                        }
                        if(item.user_level_id >0 && !this.user.group_id.includes(item.user_level_id)){
                            
                            Fast.api.layer.confirm('本小组为申请制,仅提交申请并审核通过的会员可加入', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleAudit(item.user_level_id);
                            });
                            return ;
                        }
                       
                        this.itemTab = item.id;
                        window.location.href = '/wdgroup?wdid='+item.id;
                    },
                    handleSort(sort) {
                        this.sortBy = sort;
                        this.handleShow();
                    }, 
                    handleBuy(){
                        Fast.api.open('/member/level','会员购买',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleAudit(level){
                        Fast.api.open('/member/audit?id='+level,'我要申请',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleShow() {
                        
                        this.dateRange.start = document.querySelector('[name="start"]').value;
                        this.dateRange.end = document.querySelector('[name="end"]').value;
                        this.page = 1;
                        this.more = true;
                        this.getData();                       
                    },
                    handleCurrent(tab) {
                        this.currentTab = tab;
                        this.handleShow();
                    },
                    getData(){
                        let that = this;
                        if(that.more == false){
                            return;
                        }
                        if(that.page > 1){
                            if(!this.user){
                                window.location.href = '/login';
                                return;
                            }
                            if(this.user.level == 0){
                                Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                    Fast.api.close(index);
                                    that.handleBuy();
                                });
                                return ;
                            }
                        }
                        // 在这里处理日期变化后的逻辑
                        const form = {
                            keywords:this.searchQuery,
                            index:this.currentTab,
                            sort:this.sortBy,
                            start:this.dateRange.start,
                            end:this.dateRange.end,
                            page:this.page
                        }
                        let page = this.page;
                        Fast.api.ajax({
                            url: '/reward',
                            data: form,
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                   if(that.page == 1){
                                    that.list = result.data;
                                   }else{
                                    that.list.push(...result.data);
                                   }
                                   if(result.data.length <10){
                                    that.more = false;
                                   }
                                   that.page = page+1;
                                }
                                
                            }
                        });
                    },
                    handleSearch() {
                        if (!this.searchQuery) {
                            this.suggestions = [];
                            this.showSuggestions = false;
                            return;
                        } 
                        Fast.api.ajax({
                            url: 'ajax/searchlog',
                            data: {
                                query: this.searchQuery,
                            },
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                    that.suggestions = result.data;
                                    that.showSuggestions = true;
                                    that.selectedIndex = -1;
                                }
                            }
                        });
                        
                    },
                    handleKeyDown(e) {
                        if (!this.suggestions.length) return;
                    
                        switch(e.key) {
                            case 'ArrowDown':
                                e.preventDefault();
                                this.selectedIndex = (this.selectedIndex + 1) % this.suggestions.length;
                                break;
                            case 'ArrowUp':
                                e.preventDefault();
                                this.selectedIndex = this.selectedIndex <= 0 ? this.suggestions.length - 1 : this.selectedIndex - 1;
                                break;
                            case 'Enter':
                                if (this.selectedIndex > -1) {
                                    this.selectSuggestion(this.suggestions[this.selectedIndex]);
                                } else {
                                    this.submitSearch();
                                }
                                break;
                            case 'Escape':
                                this.showSuggestions = false;
                                break;
                        }
                    },
                    selectSuggestion(item) {
                        this.searchQuery = item.name;
                        this.showSuggestions = false;
                        
                    },
                    submitSearch() {
                       this.handleShow();
                    },
                    handleSelect(){
                       this.selectTabble = !this.selectTabble;
                    }
                }
            });
    
        },
        adviser:function(){
            const vm =new Vue({
                el: '#app',
                data:{
                    commondata:['wr','week','days','fa'],
                    wdgroud:['wd','wf'],
                    selectTabble:true,               
                    user:null,//用户信息
                    head:[], //头部导航
                    banner:[],//轮播图
                    searchQuery: '',//搜索框
                    suggestions: [],//搜索建议
                    showSuggestions: false,//是否显示建议列表
                    selectedIndex: -1,//当前选中的建议索引
                    currentCategory: 0,//当前选中的分类
                    expandedCategories: {},//展开的分类
                    currentTab:'all',//当前选中的tab
                    itemTab:0,
                    page:1,
                    list:[],
                    wdcate:[],//分类
                    sortBy: 'latest',
                    dateRange: {
                        start:'',
                        end:''
                    },
                    more:true,
                    officialColumns: [
                        { title: '令牌悬赏', postCount: 165, image: '/assets/img/logo.png', url: '#' },
                        { title: '会员日', postCount: 302, image: '/assets/img/logo.png', url: '#' },
                        { title: '闻钱的收藏', postCount: 1030, image: '/assets/img/logo.png', url: '#' }
                    ],
                },
                created() {
                    that = this;
                    Fast.api.ajax({
                        url: "ajax/auth",
                        loading: false,
                        async:true,
                        success:function(result) {
                            if (result.code == 200) {
                                that.user = result.data;
                            }
                        }
                    });
                    Fast.api.ajax({
                        url: "ajax/getcate",
                        loading: false,
                        async:true,
                        success:function(result) {

                            if (result.code == 200) {
                                that.head = result.data.head;
                            }
                        }
                    });

                    
                },
                mounted() {
                    if (this.$el.contains(this.$refs.loadNode)) {
                        this.$el.removeChild(this.$refs.loadNode);
                    }
                    // 点击页面其他地方时关闭建议列表
                    document.addEventListener('click', (e) => {
                        if (!e.target.closest('.search-box')) {
                            that.showSuggestions = false;
                        }
                    });
                   
                    
                },
                
                methods:{
                    showFlag(id){
                        Fast.api.open('/member/submit?c=flag&t=document&id='+id,'赠送锦旗',{
                            maxmin: false,
                            shadeClose:false,
                            area:['300px','400px'],
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showComment(id){
                        Fast.api.open('/member/submit?c=comment&t=document&id='+id,'我要评论',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    showFavorites(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'document',id:id,c:'fa'},
                        });
                    },
                    showFollow(id){
                        Fast.api.ajax({
                            url: "member/submit",
                            loading: false,
                            async:true,
                            data:{t:'document',id:id,c:'fo'},
                        });
                    },
                    handleScroll() {
                        const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
                        const windowHeight = window.innerHeight || document.documentElement.clientHeight;
                        const documentHeight = document.documentElement.scrollHeight;
                        if (scrollTop + windowHeight >= (documentHeight-30)) {
                            that.getData();
                        }
                    },
                    handle(url,isLogin){

                        if(isLogin && !this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(isLogin && this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        window.location.href = url;
                    },
                    handleDetail(item){
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        switch (item.type) {
                            case 'wd':
                                url = '/wdgroup/detail?id='+item.doc_id;
                                break;
                            case 'wf':
                                url = '/wfgroup/detail?id='+item.doc_id;
                                break;
                            case 'wp':
                                url = '/wpgroup/detail?id='+item.doc_id;
                                break;
                            case 'wr':
                                if(this.user.level == 0){
                                    Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                                        Fast.api.close(index);
                                        that.handleBuy();
                                    });
                                    return;
                                }
                                url = '/resource/detail?id='+item.doc_id;
                                break;
                            case 'fa':
                                    url = '/favorites/detail?id='+item.doc_id;
                                    break;
                            case 'week':
                                url = '/week/detail?id='+item.doc_id;
                                break;
                            case 'days':
                                url = '/days/detail?id='+item.doc_id;
                                break;
                        }
                        window.location.href = url;
                    },
                    handCate(item){
                        if(!this.user){
                            window.location.href = '/login';
                            return;
                        }
                        if(this.user.level == 0){
                            Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(){
                                that.handleBuy();
                            });
                            return ;
                        }
                        if(item.user_level_id >0 && !this.user.group_id.includes(item.user_level_id)){
                            
                            Fast.api.layer.confirm('本小组为申请制,仅提交申请并审核通过的会员可加入', {title:'提示',icon: 3}, function(index){
                                Fast.api.close(index);
                                that.handleAudit(item.user_level_id);
                            });
                            return ;
                        }
                       
                        this.itemTab = item.id;
                        window.location.href = '/wdgroup?wdid='+item.id;
                    },
                    handleSort(sort) {
                        this.sortBy = sort;
                        this.handleShow();
                    }, 
                    handleBuy(){
                        Fast.api.open('/member/level','会员购买',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleAudit(level){
                        Fast.api.open('/member/audit?id='+level,'我要申请',{
                            minmax: false,
                            shadeClose:false,
                            shade:0.3,
                            callback: function (data) {
                                if(data.code == 1){
                                    Fast.api.close();
                                    Fast.api.success(data.msg);
                                }else{
                                    Fast.api.error(data.msg);
                                }
                            }
                        });
                    },
                    handleShow() {
                        
                        this.dateRange.start = document.querySelector('[name="start"]').value;
                        this.dateRange.end = document.querySelector('[name="end"]').value;
                        this.page = 1;
                        this.more = true;
                                             
                    },
                    handleCurrent(tab) {
                        this.currentTab = tab;
                        this.handleShow();
                    },
                    getData(){
                        let that = this;
                        if(that.more == false){
                            return;
                        }
                        if(that.page > 1){
                         this.user.level==0 &&   Fast.api.layer.confirm('需要成为闻道会员可访问', {title:'提示',icon: 3}, function(index){
                            Fast.api.close(index);
                                that.handleBuy();
                            });
                            return;
                        }
                        // 在这里处理日期变化后的逻辑
                        const form = {
                            keywords:this.searchQuery,
                            index:this.currentTab,
                            sort:this.sortBy,
                            start:this.dateRange.start,
                            end:this.dateRange.end,
                            page:this.page
                        }
                        let page = this.page;
                        Fast.api.ajax({
                            url: 'index/index/reward',
                            data: form,
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                   if(that.page == 1){
                                    that.list = result.data;
                                   }else{
                                    that.list.push(...result.data);
                                   }
                                   if(result.data.length <10){
                                    that.more = false;
                                   }
                                   that.page = page+1;
                                }
                                
                            }
                        });
                    },
                    handleSearch() {
                        if (!this.searchQuery) {
                            this.suggestions = [];
                            this.showSuggestions = false;
                            return;
                        } 
                        Fast.api.ajax({
                            url: 'ajax/searchlog',
                            data: {
                                query: this.searchQuery,
                            },
                            async:true,
                            loading: false,
                            success:function(result) {
                                if (result.code == 200) {
                                    that.suggestions = result.data;
                                    that.showSuggestions = true;
                                    that.selectedIndex = -1;
                                }
                            }
                        });
                        
                    },
                    handleKeyDown(e) {
                        if (!this.suggestions.length) return;
                    
                        switch(e.key) {
                            case 'ArrowDown':
                                e.preventDefault();
                                this.selectedIndex = (this.selectedIndex + 1) % this.suggestions.length;
                                break;
                            case 'ArrowUp':
                                e.preventDefault();
                                this.selectedIndex = this.selectedIndex <= 0 ? this.suggestions.length - 1 : this.selectedIndex - 1;
                                break;
                            case 'Enter':
                                if (this.selectedIndex > -1) {
                                    this.selectSuggestion(this.suggestions[this.selectedIndex]);
                                } else {
                                    this.submitSearch();
                                }
                                break;
                            case 'Escape':
                                this.showSuggestions = false;
                                break;
                        }
                    },
                    selectSuggestion(item) {
                        this.searchQuery = item.name;
                        this.showSuggestions = false;
                        
                    },
                    submitSearch() {
                       this.handleShow();
                    },
                    handleSelect(){
                       this.selectTabble = !this.selectTabble;
                    }
                }
            });
        }
    };
    
    return Controller;
});
